﻿using AgencyManagerSystem.Common;
using AgencyManagerSystem.DataFetcher;
using AgencyManagerSystem.DataUpdater;
using AgencyManagerSystem.Model;
using AgencyManagerSystem.AsmType;
using System;
using System.Collections.Generic;

namespace AgencyManagerSystem.Core
{
    public class SupplierMemberManager : DocManager<SupplierMemberModel>
    {
        SupplierMemberUpdater updater;

        protected override BaseUpdater<SupplierMemberModel> InjectionUpdater()
        {
            SupplierMemberUpdaterCreator suppilerUpdaterCreator = new SupplierMemberUpdaterCreator();
            updater = suppilerUpdaterCreator.CreateSupplierUpdaterInstance();
            return updater;
        }
        public virtual AsmArray<SupplierMemberModel> UpdateList(int retail, IEnumerable<SupplierMemberModel> models)
        {
            string message;
            bool result = updater.UpdateForSupplier(retail, models, out message);
            if (!result)
            {
                DBHelper.Commit( false);
                return new AsmArray<SupplierMemberModel>() { Message = message, Result = AmsCode.InnError };
            }
            else
            {
                return new AsmArray<SupplierMemberModel>() { Message = "操作成功", Result = AmsCode.Succ, Data = models };
            }
        }
    }
}
